package net.projecteuler.prob;

public class Problem45 implements Runnable {

	@Override
	public void run() {
		for(long i = 0 ; i < Integer.MAX_VALUE; i++){
			long hexaNum = (i+1)*(2*i + 1);
			if(!isPentaNum(hexaNum))
				continue;
			System.out.println(hexaNum);
		}
	}
	
	private boolean isPentaNum(long value){
		double test = (Math.sqrt(24.0 * (double)value + 1.0) + 1.0) / 6.0;
		if(Math.abs(test - Math.round(test)) == 0.0){
			return true;
		}
		return false;
	}

}
